//Jacob Kirkendall

import

java.util.*;

import

java.awt.*;

import

java.awt.event.WindowAdapter;

import

java.awt.event.WindowEvent;



public class Assignment3 extends Canvas{

public float ax,ay,bx,by,cx,cy,dx,dy,ex,ey,fx,fy; //hexagonal vertices

public float px,py,qx,qy,rx,ry,sx,sy;	//rectangular vertices

public float px1,py1,qx1,qy1,rx1,ry1,sx1,sy1;	//rectangular vertices

public float px2,py2,qx2,qy2,rx2,ry2,sx2,sy2;	//rectangular vertices

public float px3,py3,qx3,qy3,rx3,ry3,sx3,sy3;	//rectangular vertices

public float px4,py4,qx4,qy4,rx4,ry4,sx4,sy4;	//rectangular vertices

public float px5,py5,qx5,qy5,rx5,ry5,sx5,sy5;	//rectangular vertices

public float jx,jy,kx,ky,lx,ly;	//triangular vertices

public float jx1,jy1,kx1,ky1,lx1,ly1;	//triangular vertices

public float jx2,jy2,kx2,ky2,lx2,ly2;	//triangular vertices

public float jx3,jy3,kx3,ky3,lx3,ly3;	//triangular vertices

public float jx4,jy4,kx4,ky4,lx4,ly4;	//triangular vertices

public float jx5,jy5,kx5,ky5,lx5,ly5;	//triangular vertices

public float xA,yA,xB,yB,xC,yC,xD,yD,xE,yE,xF,yF,xG,yG,xH,yH,xI,yI,xJ,yJ,xK,yK,xL,yL; //dodecagonal vertices

public float s;	//side length

public float halfS;	//side length /2

public float h;	//height of triangle

public float centerx, centery;	//center point coordinates

public float scale=0.9999f; //scale factor

public float q=1-scale;	//1-scale factor

public double num=99999;	//number of shapes

public Assignment3(){

super();

initVert();

}

public void initVert(){

centerx= getWidth()/2;

centery= getHeight()/2;

s= getWidth()/10;

halfS= 0.5f*s;

h=(float)(Math.sqrt(3)*halfS);

//hexagonal

ax=centerx-halfS;

ay=centery-h;

bx=centerx+halfS;

by=centery-h;

cx=centerx+s;

cy=centery;

dx=centerx+halfS;

dy=centery+h;

ex=centerx-halfS;

ey=centery+h;

fx=centerx-s;

fy=centery;

//rectangles

px=ax;

py=ay-s;

qx=bx;

qy=by-s;

rx=bx; ry=by;

sx=ax; sy=ay;

px=ax;

py=ay-s;

qx=bx;

qy=by-s;

rx=bx; ry=by;

sx=ax; sy=ay;

//triangle

jx=qx;

jy=qy;

kx=bx+h;

ky=by-halfS;

lx=rx;

ly=ry;

//triangle1

jx1=px;

jy1=py;

kx1=px-h;

ky1=py+halfS;

lx1=sx;

ly1=sy;

//triangle2

jx2=cx+h;

jy2=cy-halfS;

kx2=cx+h;

ky2=cy+halfS;

lx2=cx;

ly2=cy;

//triangle3

jx3=fx-h;

jy3=fy-halfS;

kx3=fx-h;

ky3=fy+halfS;

lx3=fx;

ly3=fy;

//triangle4

jx4=qx;

jy4=centery+(centery-qy);

kx4=bx+h;

ky4=centery+(centery-(by-halfS));

lx4=rx;

ly4=centery+(centery-ry);

//triangle5

jx5=px;

jy5=centery+(centery-py);

kx5=px-h;

ky5=centery+(centery-(py+halfS));

lx5=sx;

ly5=centery+(centery-sy);

//rectangle1

px1=kx;

py1=ky;

qx1=cx+h;

qy1=cy-halfS;

rx1=cx; ry1=cy;

sx1=bx; sy1=by;

//rectangle2

px2=kx1;

py2=ky1;

qx2=fx-h;

qy2=fy-halfS;

rx2=fx; ry2=fy;

sx2=ax; sy2=ay;

//rectangle3

px3=kx;

py3=centery+(centery-ky);

qx3=cx+h;

qy3=centery+(centery-(cy-halfS));

rx3=cx; ry3=centery+(centery-cy);

sx3=bx; sy3=centery+(centery-by);

//rectangle4

px4=kx1;

py4=centery+(centery-ky1);

qx4=fx-h;

qy4=centery+(centery-(fy-halfS));

rx4=fx; ry4=centery+(centery-fy);

sx4=ax; sy4=centery+(centery-ay);

//rectangle5

px5=ax;

py5=centery+(centery-(ay-s));

qx5=bx;

qy5=centery+(centery-(by-s));

rx5=bx; ry5=centery+(centery-by);

sx5=ax; sy5=centery+(centery-ay);

//dodecagon

xA=px;

yA=py;

xB=qx;

yB=qy;

xC=px1;

yC=py1;

xD=qx1;

yD=qy1;

xE=qx3;

yE=qy3;

xF=px3;

yF=py3;

xG=qx5;

yG=qy5;

xH=px5;

yH=py5;

xI=px4;

yI=py4;

xJ=qx4;

yJ=qy4;

xK=qx2;

yK=qy2;

xL=px2;

yL=py2;

}

public void paint(Graphics g){

initVert();

double red=255, green=255, blue=100;

double red2=255, green2=255, blue2=100;

//dodeca

g.setColor(Color.

black);

g.drawLine((

int)xA, (int)yA, (int)xB,(int) yB);

g.drawLine((

int)xB, (int)yB, (int)xC,(int) yC);

g.drawLine((

int)xC, (int)yC, (int)xD,(int) yD);

g.drawLine((

int)xD, (int)yD, (int)xE,(int) yE);

g.drawLine((

int)xE, (int)yE, (int)xF,(int) yF);

g.drawLine((

int)xF, (int)yF, (int)xG,(int) yG);

g.drawLine((

int)xG, (int)yG, (int)xH,(int) yH);

g.drawLine((

int)xH, (int)yH, (int)xI,(int) yI);

g.drawLine((

int)xI, (int)yI, (int)xJ,(int) yJ);

g.drawLine((

int)xJ, (int)yJ, (int)xK,(int) yK);

g.drawLine((

int)xK, (int)yK, (int)xL,(int) yL);

g.drawLine((

int)xL, (int)yL, (int)xA,(int) yA);

//hex

g.setColor(

new Color((int)red,(int)green,(int)blue));

g.drawLine((

int)ax, (int)ay, (int)bx,(int) by);

g.drawLine((

int)bx, (int)by, (int)cx,(int) cy);

g.drawLine((

int)cx, (int)cy, (int)dx,(int) dy);

g.drawLine((

int)dx, (int)dy, (int)ex,(int) ey);

g.drawLine((

int)ex, (int)ey, (int)fx,(int) fy);

g.drawLine((

int)ax, (int)ay, (int)fx,(int) fy);

//rect

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px, (int)py, (int)qx,(int) qy);

g.drawLine((

int)qx, (int)qy, (int)rx,(int) ry);

g.drawLine((

int)rx, (int)ry, (int)sx,(int) sy);

g.drawLine((

int)sx, (int)sy, (int)px,(int) py);

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px1, (int)py1, (int)qx1,(int) qy1);

g.drawLine((

int)qx1, (int)qy1, (int)rx1,(int) ry1);

g.drawLine((

int)rx1, (int)ry1, (int)sx1,(int) sy1);

g.drawLine((

int)sx1, (int)sy1, (int)px1,(int) py1);

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px2, (int)py2, (int)qx2,(int) qy2);

g.drawLine((

int)qx2, (int)qy2, (int)rx2,(int) ry2);

g.drawLine((

int)rx2, (int)ry2, (int)sx2,(int) sy2);

g.drawLine((

int)sx2, (int)sy2, (int)px2,(int) py2);

//tri

g.drawLine((

int)jx, (int)jy, (int)kx,(int) ky);

g.drawLine((

int)kx, (int)ky, (int)lx,(int) ly);

g.drawLine((

int)jx, (int)jy, (int)lx,(int) ly);

g.drawLine((

int)jx1, (int)jy1, (int)kx1,(int) ky1);

g.drawLine((

int)kx1, (int)ky1, (int)lx1,(int) ly1);

g.drawLine((

int)jx1, (int)jy1, (int)lx1,(int) ly1);

//HEXAGON

for(int i=0;i<=num;i++){

float axnew=ax*scale+fx*q; float aynew=ay*scale+fy*q;

float cxnew=cx*scale+bx*q; float cynew=cy*scale+by*q;

float bxnew=bx*scale+ax*q; float bynew=by*scale+ay*q;

float dxnew=dx*scale+cx*q; float dynew=dy*scale+cy*q;

float exnew=ex*scale+dx*q; float eynew=ey*scale+dy*q;

float fxnew=fx*scale+ex*q; float fynew=fy*scale+ey*q;

ax=axnew; ay=aynew;

bx=bxnew; by=bynew;

cx=cxnew; cy=cynew;

dx=dxnew; dy=dynew;

ex=exnew; ey=eynew;

fx=fxnew; fy=fynew;

g.setColor(

new Color((int)red, (int)green, (int)blue));

g.drawLine((

int)ax, (int)ay, (int)bx,(int) by);

g.drawLine((

int)bx, (int)by, (int)cx,(int) cy);

g.drawLine((

int)cx, (int)cy, (int)dx,(int) dy);

g.drawLine((

int)dx, (int)dy, (int)ex,(int) ey);

g.drawLine((

int)ex, (int)ey, (int)fx,(int) fy);

g.drawLine((

int)ax, (int)ay, (int)fx,(int) fy);

if(green>0 && i<num/2){

green-=255/((

double)num/2.0);

}

else if(((int)green<255 || (int)blue<255) && i>=num/2){

blue+=255/((

double)num-(double)num/2.0);

green+=255/((

double)num-(double)num/2.0);

}

if(blue>255 || green>255){

blue=255;

green=255;

}

}

//RECTANGLE

for(int j=0;j<num;j++){

float pxnew=px*scale+sx*q; float pynew=py*scale+sy*q;

float qxnew=qx*scale+px*q; float qynew=qy*scale+py*q;

float rxnew=rx*scale+qx*q; float rynew=ry*scale+qy*q;

float sxnew=sx*scale+rx*q; float synew=sy*scale+ry*q;

px=pxnew; py=pynew;

qx=qxnew; qy=qynew;

rx=rxnew; ry=rynew;

sx=sxnew; sy=synew;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px, (int)py, (int)qx,(int) qy);

g.drawLine((

int)qx, (int)qy, (int)rx,(int) ry);

g.drawLine((

int)rx, (int)ry, (int)sx,(int) sy);

g.drawLine((

int)sx, (int)sy, (int)px,(int) py);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//RECTANGLE 1

for(int j=0;j<num;j++){

float px1new=px1*scale+sx1*q; float py1new=py1*scale+sy1*q;

float qx1new=qx1*scale+px1*q; float qy1new=qy1*scale+py1*q;

float rx1new=rx1*scale+qx1*q; float ry1new=ry1*scale+qy1*q;

float sx1new=sx1*scale+rx1*q; float sy1new=sy1*scale+ry1*q;

px1=px1new; py1=py1new;

qx1=qx1new; qy1=qy1new;

rx1=rx1new; ry1=ry1new;

sx1=sx1new; sy1=sy1new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px1, (int)py1, (int)qx1,(int) qy1);

g.drawLine((

int)qx1, (int)qy1, (int)rx1,(int) ry1);

g.drawLine((

int)rx1, (int)ry1, (int)sx1,(int) sy1);

g.drawLine((

int)sx1, (int)sy1, (int)px1,(int) py1);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//RECTANGLE 2

for(int j=0;j<num;j++){

float px2new=px2*scale+sx2*q; float py2new=py2*scale+sy2*q;

float qx2new=qx2*scale+px2*q; float qy2new=qy2*scale+py2*q;

float rx2new=rx2*scale+qx2*q; float ry2new=ry2*scale+qy2*q;

float sx2new=sx2*scale+rx2*q; float sy2new=sy2*scale+ry2*q;

px2=px2new; py2=py2new;

qx2=qx2new; qy2=qy2new;

rx2=rx2new; ry2=ry2new;

sx2=sx2new; sy2=sy2new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px2, (int)py2, (int)qx2,(int) qy2);

g.drawLine((

int)qx2, (int)qy2, (int)rx2,(int) ry2);

g.drawLine((

int)rx2, (int)ry2, (int)sx2,(int) sy2);

g.drawLine((

int)sx2, (int)sy2, (int)px2,(int) py2);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//RECTANGLE 3

for(int j=0;j<num;j++){

float px3new=px3*scale+sx3*q; float py3new=py3*scale+sy3*q;

float qx3new=qx3*scale+px3*q; float qy3new=qy3*scale+py3*q;

float rx3new=rx3*scale+qx3*q; float ry3new=ry3*scale+qy3*q;

float sx3new=sx3*scale+rx3*q; float sy3new=sy3*scale+ry3*q;

px3=px3new; py3=py3new;

qx3=qx3new; qy3=qy3new;

rx3=rx3new; ry3=ry3new;

sx3=sx3new; sy3=sy3new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px3, (int)py3, (int)qx3,(int) qy3);

g.drawLine((

int)qx3, (int)qy3, (int)rx3,(int) ry3);

g.drawLine((

int)rx3, (int)ry3, (int)sx3,(int) sy3);

g.drawLine((

int)sx3, (int)sy3, (int)px3,(int) py3);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//RECTANGLE 4

for(int j=0;j<num;j++){

float px4new=px4*scale+sx4*q; float py4new=py4*scale+sy4*q;

float qx4new=qx4*scale+px4*q; float qy4new=qy4*scale+py4*q;

float rx4new=rx4*scale+qx4*q; float ry4new=ry4*scale+qy4*q;

float sx4new=sx4*scale+rx4*q; float sy4new=sy4*scale+ry4*q;

px4=px4new; py4=py4new;

qx4=qx4new; qy4=qy4new;

rx4=rx4new; ry4=ry4new;

sx4=sx4new; sy4=sy4new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px4, (int)py4, (int)qx4,(int) qy4);

g.drawLine((

int)qx4, (int)qy4, (int)rx4,(int) ry4);

g.drawLine((

int)rx4, (int)ry4, (int)sx4,(int) sy4);

g.drawLine((

int)sx4, (int)sy4, (int)px4,(int) py4);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//RECTANGLE 5

for(int j=0;j<num;j++){

float px5new=px5*scale+sx5*q; float py5new=py5*scale+sy5*q;

float qx5new=qx5*scale+px5*q; float qy5new=qy5*scale+py5*q;

float rx5new=rx5*scale+qx5*q; float ry5new=ry5*scale+qy5*q;

float sx5new=sx5*scale+rx5*q; float sy5new=sy5*scale+ry5*q;

px5=px5new; py5=py5new;

qx5=qx5new; qy5=qy5new;

rx5=rx5new; ry5=ry5new;

sx5=sx5new; sy5=sy5new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)px5, (int)py5, (int)qx5,(int) qy5);

g.drawLine((

int)qx5, (int)qy5, (int)rx5,(int) ry5);

g.drawLine((

int)rx5, (int)ry5, (int)sx5,(int) sy5);

g.drawLine((

int)sx5, (int)sy5, (int)px5,(int) py5);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//TRIANGLE

for(int j=0;j<num;j++){

float jxnew=jx*scale+lx*q; float jynew=jy*scale+ly*q;

float kxnew=kx*scale+jx*q; float kynew=ky*scale+jy*q;

float lxnew=lx*scale+kx*q; float lynew=ly*scale+ky*q;

jx=jxnew; jy=jynew;

kx=kxnew; ky=kynew;

lx=lxnew; ly=lynew;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)jx, (int)jy, (int)kx,(int) ky);

g.drawLine((

int)kx, (int)ky, (int)lx,(int) ly);

g.drawLine((

int)lx, (int)ly, (int)jx,(int) jy);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//TRIANGLE 1

for(int j=0;j<num;j++){

float jx1new=jx1*scale+lx1*q; float jy1new=jy1*scale+ly1*q;

float kx1new=kx1*scale+jx1*q; float ky1new=ky1*scale+jy1*q;

float lx1new=lx1*scale+kx1*q; float ly1new=ly1*scale+ky1*q;

jx1=jx1new; jy1=jy1new;

kx1=kx1new; ky1=ky1new;

lx1=lx1new; ly1=ly1new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)jx1, (int)jy1, (int)kx1,(int) ky1);

g.drawLine((

int)kx1, (int)ky1, (int)lx1,(int) ly1);

g.drawLine((

int)lx1, (int)ly1, (int)jx1,(int) jy1);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//TRIANGLE 2

for(int j=0;j<num;j++){

float jx2new=jx2*scale+lx2*q; float jy2new=jy2*scale+ly2*q;

float kx2new=kx2*scale+jx2*q; float ky2new=ky2*scale+jy2*q;

float lx2new=lx2*scale+kx2*q; float ly2new=ly2*scale+ky2*q;

jx2=jx2new; jy2=jy2new;

kx2=kx2new; ky2=ky2new;

lx2=lx2new; ly2=ly2new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)jx2, (int)jy2, (int)kx2,(int) ky2);

g.drawLine((

int)kx2, (int)ky2, (int)lx2,(int) ly2);

g.drawLine((

int)lx2, (int)ly2, (int)jx2,(int) jy2);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//TRIANGLE 3

for(int j=0;j<num;j++){

float jx3new=jx3*scale+lx3*q; float jy3new=jy3*scale+ly3*q;

float kx3new=kx3*scale+jx3*q; float ky3new=ky3*scale+jy3*q;

float lx3new=lx3*scale+kx3*q; float ly3new=ly3*scale+ky3*q;

jx3=jx3new; jy3=jy3new;

kx3=kx3new; ky3=ky3new;

lx3=lx3new; ly3=ly3new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)jx3, (int)jy3, (int)kx3,(int) ky3);

g.drawLine((

int)kx3, (int)ky3, (int)lx3,(int) ly3);

g.drawLine((

int)lx3, (int)ly3, (int)jx3,(int) jy3);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//TRIANGLE 4

for(int j=0;j<num;j++){

float jx4new=jx4*scale+lx4*q; float jy4new=jy4*scale+ly4*q;

float kx4new=kx4*scale+jx4*q; float ky4new=ky4*scale+jy4*q;

float lx4new=lx4*scale+kx4*q; float ly4new=ly4*scale+ky4*q;

jx4=jx4new; jy4=jy4new;

kx4=kx4new; ky4=ky4new;

lx4=lx4new; ly4=ly4new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)jx4, (int)jy4, (int)kx4,(int) ky4);

g.drawLine((

int)kx4, (int)ky4, (int)lx4,(int) ly4);

g.drawLine((

int)lx4, (int)ly4, (int)jx4,(int) jy4);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

//TRIANGLE 5

for(int j=0;j<num;j++){

float jx5new=jx5*scale+lx5*q; float jy5new=jy5*scale+ly5*q;

float kx5new=kx5*scale+jx5*q; float ky5new=ky5*scale+jy5*q;

float lx5new=lx5*scale+kx5*q; float ly5new=ly5*scale+ky5*q;

jx5=jx5new; jy5=jy5new;

kx5=kx5new; ky5=ky5new;

lx5=lx5new; ly5=ly5new;

g.setColor(

new Color((int)red2, (int)green2, (int)blue2));

g.drawLine((

int)jx5, (int)jy5, (int)kx5,(int) ky5);

g.drawLine((

int)kx5, (int)ky5, (int)lx5,(int) ly5);

g.drawLine((

int)lx5, (int)ly5, (int)jx5,(int) jy5);

if(green2>0 && j<num/4){

green2-=255/((

double)num/4.0);

}

else if(((int)green2<255 || (int)blue2<255) && j>=num/4){

blue2+=255/((

double)num-(double)num/1.5);

green2+=255/((

double)num-(double)num/1.5);

}

if(blue2>255 || green2>255){

blue2=255;

green2=255;

}

}

red2=255; green2=255; blue2=100;

red=Color.orange.getRed(); green= Color.

orange.getGreen(); blue=Color.orange.getBlue();

int rouge=255, vert=150, bleu=120;

Color color1=

new Color((int)red2,(int)green2,(int)blue2);

color1=color1.brighter();

Color color2=

new Color((int)red,(int)green,(int)blue);

color2=color2.brighter();

Color color3=

new Color(rouge,vert,bleu);

color3=color3.brighter();

double ratio1r=((-color1.getRed())+Color.pink.getRed())/num;

double ratio2r=((-color2.getRed())+Color.pink.getRed())/num;

double ratio3r=((-color3.getRed())+Color.pink.getRed())/num;

double ratio1g=((-color1.getGreen())+Color.pink.getGreen())/num;

double ratio2g=((-color2.getGreen())+Color.pink.getGreen())/num;

double ratio3g=((-color3.getGreen())+Color.pink.getGreen())/num;

double ratio1b=((-color1.getBlue())+Color.pink.getBlue())/num;

double ratio2b=((-color2.getBlue())+Color.pink.getBlue())/num;

double ratio3b=((-color3.getBlue())+Color.pink.getBlue())/num;

scale=1.00002f;

q=1-scale;

//DODECAGON

for(int i=0;i<=num;i++){

float xAnew=xA*scale+xL*q; float yAnew=yA*scale+yL*q;

float xCnew=xC*scale+xB*q; float yCnew=yC*scale+yB*q;

float xBnew=xB*scale+xA*q; float yBnew=yB*scale+yA*q;

float xDnew=xD*scale+xC*q; float yDnew=yD*scale+yC*q;

float xEnew=xE*scale+xD*q; float yEnew=yE*scale+yD*q;

float xFnew=xF*scale+xE*q; float yFnew=yF*scale+yE*q;

float xGnew=xG*scale+xF*q; float yGnew=yG*scale+yF*q;

float xHnew=xH*scale+xG*q; float yHnew=yH*scale+yG*q;

float xInew=xI*scale+xH*q; float yInew=yI*scale+yH*q;

float xJnew=xJ*scale+xI*q; float yJnew=yJ*scale+yI*q;

float xKnew=xK*scale+xJ*q; float yKnew=yK*scale+yJ*q;

float xLnew=xL*scale+xK*q; float yLnew=yL*scale+yK*q;

xA=xAnew; yA=yAnew;

xB=xBnew; yB=yBnew;

xC=xCnew; yC=yCnew;

xD=xDnew; yD=yDnew;

xE=xEnew; yE=yEnew;

xF=xFnew; yF=yFnew;

xG=xGnew; yG=yGnew;

xH=xHnew; yH=yHnew;

xI=xInew; yI=yInew;

xJ=xJnew; yJ=yJnew;

xK=xKnew; yK=yKnew;

xL=xLnew; yL=yLnew;

g.setColor(color1);

g.drawLine((

int)xA, (int)yA, (int)xB,(int) yB);

g.setColor(color2);

g.drawLine((

int)xB, (int)yB, (int)xC,(int) yC);

g.setColor(color3);

g.drawLine((

int)xC, (int)yC, (int)xD,(int) yD);

g.setColor(color1);

g.drawLine((

int)xD, (int)yD, (int)xE,(int) yE);

g.setColor(color2);

g.drawLine((

int)xE, (int)yE, (int)xF,(int) yF);

g.setColor(color3);

g.drawLine((

int)xF, (int)yF, (int)xG,(int) yG);

g.setColor(color1);

g.drawLine((

int)xG, (int)yG, (int)xH,(int) yH);

g.setColor(color2);

g.drawLine((

int)xH, (int)yH, (int)xI,(int) yI);

g.setColor(color3);

g.drawLine((

int)xI, (int)yI, (int)xJ,(int) yJ);

g.setColor(color1);

g.drawLine((

int)xJ, (int)yJ, (int)xK,(int) yK);

g.setColor(color2);

g.drawLine((

int)xK, (int)yK, (int)xL,(int) yL);

g.setColor(color3);

g.drawLine((

int)xL, (int)yL, (int)xA,(int) yA);

red2+=ratio1r;

green2+=ratio1g;

blue2+=ratio1b;

color1= new Color((int)(red2),(int)(green2), (int)(blue2));

red+=ratio2r;

green+=ratio2g;

blue+=ratio2b;

color2= new Color((int)(red),(int)(green), (int)(blue));

rouge+=ratio3r;

vert+=ratio3g;

bleu+=ratio3b;

color3= new Color((int)(rouge),(int)(vert), (int)(bleu));


}

}

public static void main(String[] args){

Frame myFrame=

new Frame();

myFrame.setBackground(Color.

pink);

myFrame.setSize(1024,768);

Assignment3 blah=

new Assignment3();

myFrame.add(blah);

//if window closes, then program stops running

WindowAdapter wind=

new WindowAdapter() {

public void windowClosing(WindowEvent e){	System.exit(0);	}

};

myFrame.addWindowListener(wind);

myFrame.setVisible(

true);

}

}